package fr.m2if.main;

import java.util.ArrayList;
import java.util.List;

public class User {

	private String name;
	private String lastName;
	private List<Livre> emprunts;
	private boolean interdit;
	
	public User(){
		emprunts=new ArrayList<Livre>();
	}
	
	public User(String pName, String pLastName){
		name=pName;
		lastName=pLastName;
		interdit=false;
		emprunts=new ArrayList<Livre>();
	}
	
	@Override
	public String toString() {
		return "User [name=" + name + ", lastName=" + lastName + ", interdit=" + interdit + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((emprunts == null) ? 0 : emprunts.hashCode());
		result = prime * result + (interdit ? 1231 : 1237);
		result = prime * result
				+ ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (emprunts == null) {
			if (other.emprunts != null)
				return false;
		} else if (!emprunts.equals(other.emprunts))
			return false;
		if (interdit != other.interdit)
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public List<Livre> getEmprunts() {
		return emprunts;
	}
	public void setEmprunts(List<Livre> emprunts) {
		this.emprunts = emprunts;
	}
	public boolean isInterdit() {
		return interdit;
	}
	public void setInterdit(boolean interdit) {
		this.interdit = interdit;
	}
	
}
